import React, {useEffect, useState} from 'react';
import {
  ScrollView,
  View,
  Text,
  TouchableOpacity,
  ActivityIndicator,
  FlatList,
  Image,
  TextInput,
} from 'react-native';
import {useNavigation} from '@react-navigation/native';
import AreaView from '../../components/Layout/AreaView';
import QuesDetail from '../../components/QuesDetail';
import BaseUrl from '../../config/BaseUrl';
import styles from './style';
import {getMyHworkList} from '../../service/my';

const MyJob = () => {
  const navigation = useNavigation();
  const [pn, setPn] = useState(1);
  const [list, setList] = useState([]);
  useEffect(() => {
    getMyHworkList({pn}).then((res) => {
      console.log(res);
      setList(res.rows);
    });
  }, [pn]);
  return (
    <AreaView>
      <ScrollView style={styles.container}>
        {(list || []).map((item) => (
          <View key={item.courseId} style={styles.list}>
            <View style={styles.head}>
              <View style={styles.left}>
                <Image
                  source={{uri: BaseUrl.imgurl + item.teacherImage}}
                  style={styles.avatar}
                />
                <Text style={styles.name}>{item.teacherNam}</Text>
              </View>
              <Text style={styles.time}>{item.createTime}</Text>
            </View>
            <Text style={styles.info}>{item.hworkContent}</Text>
            <View style={styles.cover_list}>
              {item.hworkImagePath.split('|').map((it, index) => (
                <Image
                  key={index}
                  style={styles.cover}
                  source={{uri: BaseUrl.imgurl + it}}
                />
              ))}
            </View>
            {/* <View style={styles.btn_container}>
              <TouchableOpacity  activeOpacity={1} style={styles.btn}>
                <Text style={styles.btn_text}>去完成作业</Text>
              </TouchableOpacity>
            </View> */}
          </View>
        ))}
      </ScrollView>
      {/* <View style={styles.job_detail}>
        <QuesDetail />
      </View> */}
    </AreaView>
  );
};

export default MyJob;
